ken by token.

a scanned token is a variable, a value assigned to the variable is

nto the stack. When a scanned token is an operator, a number of

thin the stack are popped up from the top of the stack one by one

ds for them to take part in a calculation for the operation specified

anned token. After calculation, the calculated result is pushed

he stack. When an RPN string has been fully scanned, the stack is

posed of one value as the final outcome of a system.

ose x=1, y=2, z=3 for a system ݔ൅3ݕ൅ݔݖ expressed using

*+ and a stack was denoted by S. Figure 8.6 shows how each

s scanned for the evaluation of this RPN string. The scanning

of this RPN string is shown as follows. The first token was a

x. Therefore the value of x was pushed into the stack, i.e., S = 1.

ep, the stack was only composed of one value, which was one.

nd taken was three, which was a constant. Therefore, it was also

nto the stack. The stack was now composed of two values, i.e., S

Note that the top entry of S was three, which was the last one

shed into the stack. The operation strategy of a stack was last-in-

The third token was a variable y. Therefore, the value of y was

nto the stack. The stack was now composed of three values, i.e., S

2). The fourth token was a multiplication operator (a star).

e the top two entries of S were popped up. After popping out two

es of the stack, the stack was composed of only one value, i.e., S

popped two values were used for a multiplication between them,

ൌ6. The outcome, which was six, was pushed back into the

e stack was now composed of two values, i.e., S = (1, 6). The

n was again an operator (a cross). Therefore two entries of the

e popped up leaving an empty stack, i.e., S = NULL. Two popped

s (one and six) were summed up. The outcome was then pushed

he stack. Therefore the stack became S = 7. The sixth token was

e x. Therefore, the value of x was pushed into the stack, i.e., S =

he seventh token was a variable z. Therefore the value of z was

nto the stack, i.e., S = (7, 1, 3). The eighth token was an operator

Therefore the top values of the stack (1 and 3) were popped up